package org.vectrics.recruiter.struts.admin.job;

import javax.servlet.jsp.JspException;

import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.job.JobTerm;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.struts.VectricsStrutsAction;
/**
 * @author pgoette
 * Clase encargada de Recuperar los datos del Term para editarlos.
 */

public class EditJobTermAction extends VectricsStrutsAction {

	@Override
	protected String doExecute(VectricsActionData actionData)
			throws JspException {
		
		String forward = "success";
		Long idTerm = actionData.getRequest().getLongParameter("termId");
		JobTermForm form = (JobTermForm) actionData.getForm();
		
		if (idTerm != null) {
			JobTerm term = RecruitServiceLocator.getJobProvider().findJobTerm(idTerm);
			form.setId(term.getId().toString());
			form.setCode(term.getCode());
			form.setDescription(term.getDescription());
		} else {
			forward = "invalid";
		}
		
		return forward;
	}

}
